namespace Data.Migrations
{
    using Data.DBModels;
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    public sealed class Configuration : DbMigrationsConfiguration<Data.MyDbContext.WebStudioDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            ContextKey = "Data.MyDbContext.WebStudioDbContext";
        }

        protected override void Seed(Data.MyDbContext.WebStudioDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
            //User user = new User
            //{
            //    CreatedOn = DateTime.Now,
            //    Id = new Guid("7e3c3919-c3bd-4520-9de5-e007e211c424"),
            //    Username = "kayn",
            //    Password = "123"
                 

            //};

            ////context.Set<User>().AddOrUpdate(user);

            ////User user2 = context.Set<User>().Find(user.Id);

            //List<Category> categories = new List<Category>
            //    {
            //        new Category{ Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name="News"},
            //        new Category{ Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name="IT"},
            //        new Category{ Id = Guid.NewGuid(), CreatedOn = DateTime.Now, Name="OnlineStore"}
            //    };

            //List<Website> websites = new List<Website> {
            //        new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="Yahoo", Url="www.yahoo.ca", CreatedBy_Id=user.Id, Categories= new List<Category>{categories[0]}},
            //       new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="Goole", Url="www.google.ca",CreatedBy_Id=user.Id, Categories= new List<Category>{categories[0]}}
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="CBC", Url="www.cbc.ca",CreatedBy=user2, Categories= new List<Category>{categories[0]}},
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="NewYokTime", Url="www.nytimes.com",CreatedBy=user2, Categories= new List<Category>{categories[0]}}, 
              
                    
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="Microsoft", Url="www.microsoft.com",CreatedBy=user2, Categories= new List<Category>{categories[1]}},
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="Asp", Url="www.asp.net",CreatedBy=user2, Categories= new List<Category>{categories[1]}},
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="CodeProject", Url="www.codeproject.com",CreatedBy=user2, Categories= new List<Category>{categories[1]}},
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="CodePlex", Url="www.codeplex.com",CreatedBy=user2, Categories= new List<Category>{categories[1]}},
            

            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="Amazon", Url="www.Amazon.ca",CreatedBy=user2, Categories= new List<Category>{categories[2]}},
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="Ebay", Url="www.Ebay.ca", CreatedBy=user2,Categories= new List<Category>{categories[2]}},
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="Walmart", Url="www.Walmart.ca", CreatedBy=user2,Categories= new List<Category>{categories[2]}},
            //        //new Website{ Id=Guid.NewGuid(), CreatedOn=DateTime.Now, Name="Futureshop", Url="www.futureshop.ca", CreatedBy=user2,Categories= new List<Category>{categories[2]}}
                
            //    };

            //context.Set<User>().AddOrUpdate(user);
            //// add data into context and save to db
            //foreach (Website r in websites)
            //{
            //    context.Set<Website>().AddOrUpdate(r);
            //}
            //context.SaveChanges();

        }
    }
}
